package com.example.robot;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;

@Data
@NoArgsConstructor
public class ChargeData {
    private String dateline;
    private Double todayRecharge;
    private Double yesRecharge;
    private Double rate;

    public ChargeData(double today, double yes, long dateline) {
        this.dateline = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(dateline);
        this.todayRecharge = today;
        this.yesRecharge = yes;
        this.rate = (today - yes) / yes;
    }

    @Override
    public String toString() {
        String msg = this.rate >= 0 ? "上升" : "下降";
        return String.format("%s， 今日 %s， 昨日 %s， %s %s",
                dateline,
                todayRecharge,
                yesRecharge,
                msg,
                String.format("%.2f", Math.abs(rate)));
    }
}
